#include<iostream>
#include<vector>
#include<unordered_map>
using namespace std;

class Solution {
public:
	int fourSumCount(vector<int>& nums1, vector<int>& nums2, vector<int>& nums3, vector<int>& nums4) {
		unordered_map<int, int> mapAB;
		for (int i : nums1) {
			for (int j : nums2) {
				mapAB[i + j]++;
			}
		}
		int res = 0;
		for (int i : nums3) {
			for (int j : nums4) {
				if (mapAB.count(-i - j)) {
					res += mapAB[-i - j];
				}
			}
		}
		return res;
	}
};

void main() {
	vector<int> nums1 = { 1, 2 }, nums2 = { -2, -1 }, nums3 = { -1, 2 }, nums4 = { 0, 2 };
	Solution s;
	s.fourSumCount(nums1, nums2, nums3, nums4);
}